//
// Este archivo ha sido generado por la arquitectura JavaTM para la implantación de la referencia de enlace (JAXB) XML v2.2.7 
// Visite <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen. 
// Generado el: 2014.07.22 a las 11:49:28 PM ART 
//

package org.gabrielnegri.fitparser.entities;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;

import org.gabrielnegri.fitparser.Populable;
import org.w3c.dom.Element;

import com.google.gson.annotations.Expose;

/**
 * <p>
 * Clase Java para Trackpoint_t complex type.
 * 
 * <p>
 * El siguiente fragmento de esquema especifica el contenido que se espera que
 * haya en esta clase.
 * 
 * <pre>
 * &lt;complexType name="Trackpoint_t">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="Time" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
 *         &lt;element name="Position" type="{http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2}Position_t" minOccurs="0"/>
 *         &lt;element name="AltitudeMeters" type="{http://www.w3.org/2001/XMLSchema}double" minOccurs="0"/>
 *         &lt;element name="DistanceMeters" type="{http://www.w3.org/2001/XMLSchema}double" minOccurs="0"/>
 *         &lt;element name="HeartRateBpm" type="{http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2}HeartRateInBeatsPerMinute_t" minOccurs="0"/>
 *         &lt;element name="Cadence" type="{http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2}CadenceValue_t" minOccurs="0"/>
 *         &lt;element name="SensorState" type="{http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2}SensorState_t" minOccurs="0"/>
 *         &lt;element name="Extensions" type="{http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2}Extensions_t" minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Trackpoint_t", propOrder = { "time", "position",
		"altitudeMeters", "distanceMeters", "heartRateBpm", "cadence",
		"sensorState", "extensions", "speed" , "heartRate"})
public class TrackpointT implements Populable {

	@XmlElement(name = "Time", required = true)
	@XmlSchemaType(name = "dateTime")
	@Expose
	protected XMLGregorianCalendar time;
	@XmlElement(name = "Position")
	@Expose
	protected PositionT position;
	@XmlElement(name = "AltitudeMeters")
	@Expose
	protected Double altitudeMeters;
	@XmlElement(name = "DistanceMeters")
	@Expose
	protected Double distanceMeters;
	@XmlElement(name = "HeartRateBpm")
	protected HeartRateInBeatsPerMinuteT heartRateBpm;
	@XmlElement(name = "Cadence")
	@Expose
	protected Short cadence;
	@XmlElement(name = "SensorState")
	@Expose
	protected SensorStateT sensorState;
	@XmlElement(name = "Extensions")
	protected ExtensionsT extensions;
	@XmlElement(name = "Speed")
	@Expose
	protected Double speed;
	
	@Expose
	protected short heartRate;

	/**
	 * Obtiene el valor de la propiedad time.
	 * 
	 * @return possible object is {@link XMLGregorianCalendar }
	 * 
	 */
	public XMLGregorianCalendar getTime() {
		return time;
	}

	/**
	 * Define el valor de la propiedad time.
	 * 
	 * @param value
	 *            allowed object is {@link XMLGregorianCalendar }
	 * 
	 */
	public void setTime(XMLGregorianCalendar value) {
		this.time = value;
	}

	/**
	 * Obtiene el valor de la propiedad position.
	 * 
	 * @return possible object is {@link PositionT }
	 * 
	 */
	public PositionT getPosition() {
		return position;
	}

	/**
	 * Define el valor de la propiedad position.
	 * 
	 * @param value
	 *            allowed object is {@link PositionT }
	 * 
	 */
	public void setPosition(PositionT value) {
		this.position = value;
	}

	/**
	 * Obtiene el valor de la propiedad altitudeMeters.
	 * 
	 * @return possible object is {@link Double }
	 * 
	 */
	public Double getAltitudeMeters() {
		return altitudeMeters;
	}

	/**
	 * Define el valor de la propiedad altitudeMeters.
	 * 
	 * @param value
	 *            allowed object is {@link Double }
	 * 
	 */
	public void setAltitudeMeters(Double value) {
		this.altitudeMeters = value;
	}

	/**
	 * Obtiene el valor de la propiedad distanceMeters.
	 * 
	 * @return possible object is {@link Double }
	 * 
	 */
	public Double getDistanceMeters() {
		return distanceMeters;
	}

	/**
	 * Define el valor de la propiedad distanceMeters.
	 * 
	 * @param value
	 *            allowed object is {@link Double }
	 * 
	 */
	public void setDistanceMeters(Double value) {
		this.distanceMeters = value;
	}

	/**
	 * Obtiene el valor de la propiedad heartRateBpm.
	 * 
	 * @return possible object is {@link HeartRateInBeatsPerMinuteT }
	 * 
	 */
	public HeartRateInBeatsPerMinuteT getHeartRateBpm() {
		return heartRateBpm;
	}

	/**
	 * Define el valor de la propiedad heartRateBpm.
	 * 
	 * @param value
	 *            allowed object is {@link HeartRateInBeatsPerMinuteT }
	 * 
	 */
	public void setHeartRateBpm(HeartRateInBeatsPerMinuteT value) {
		this.heartRateBpm = value;
	}

	/**
	 * Obtiene el valor de la propiedad cadence.
	 * 
	 * @return possible object is {@link Short }
	 * 
	 */
	public Short getCadence() {
		return cadence;
	}

	/**
	 * Define el valor de la propiedad cadence.
	 * 
	 * @param value
	 *            allowed object is {@link Short }
	 * 
	 */
	public void setCadence(Short value) {
		this.cadence = value;
	}

	/**
	 * Obtiene el valor de la propiedad sensorState.
	 * 
	 * @return possible object is {@link SensorStateT }
	 * 
	 */
	public SensorStateT getSensorState() {
		return sensorState;
	}

	/**
	 * Define el valor de la propiedad sensorState.
	 * 
	 * @param value
	 *            allowed object is {@link SensorStateT }
	 * 
	 */
	public void setSensorState(SensorStateT value) {
		this.sensorState = value;
	}

	/**
	 * Obtiene el valor de la propiedad extensions.
	 * 
	 * @return possible object is {@link ExtensionsT }
	 * 
	 */
	public ExtensionsT getExtensions() {
		return extensions;
	}

	/**
	 * Define el valor de la propiedad extensions.
	 * 
	 * @param value
	 *            allowed object is {@link ExtensionsT }
	 * 
	 */
	public void setExtensions(ExtensionsT value) {
		this.extensions = value;
	}

	public Double getSpeed() {
		return speed;
	}

	public void setSpeed(Double speed) {
		this.speed = speed;
	}
	
	public short getHeartRate() {
		return heartRate;
	}
	
	public void setHeartRate(short heartRate) {
		this.heartRate = heartRate;
	}

	@Override
	public void populate() {
		this.setHeartRate(this.getHeartRateBpm().getValue());
		Element speedElement = (Element) this.getExtensions().getAny().get(0);
		this.setSpeed(Double.valueOf(speedElement.getFirstChild()
				.getTextContent()));
		this.setExtensions(null);
	}

}
